Add from_onnx_text function to convert ONNX text to IR model#2291
Merged
justinchuby merged 6 commits intomainfrom May 12, 2025
Merged
Add from_onnx_text function to convert ONNX text to IR model#2291justinchuby merged 6 commits intomainfrom
justinchuby merged 6 commits intomainfrom
Conversation
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/onnxscript?shareId=XXXX-XXXX-XXXX-XXXX).
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a new API function, from_onnx_text, to convert an ONNX textual representation directly into an IR model. The changes update various test files and documentation to use the new function instead of manually parsing and deserializing ONNX text.
- Tests in version_converter, rewriter, and optimizer have been updated to use the new function.
- The ir/serde module is extended with a new helper function, and the documentation is updated accordingly.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| onnxscript/version_converter/_version_converter_test.py | Updated tests to replace onnx.parser.parse_model with from_onnx_text. |
| onnxscript/rewriter/no_op_test.py | Simplified test helper to use from_onnx_text. |
| onnxscript/optimizer/_constant_folding_test.py | Updated constant folding tests to use the new conversion function. |
| onnxscript/ir/serde.py | Added the new from_onnx_text function and updated init.py. |
| docs/ir/ir_api/core.md | Updated API documentation to include from_onnx_text. |
Comments suppressed due to low confidence (2)
onnxscript/rewriter/no_op_test.py:12
- [nitpick] It is good to see the tests using from_onnx_text; consider also adding tests for malformed ONNX text inputs to verify robust error handling.
def _check(self, model_text: str) -> None:
onnxscript/optimizer/_constant_folding_test.py:16
- [nitpick] Consider adding negative test cases with invalid or malformed ONNX text to ensure that from_onnx_text handles errors gracefully.
def _fold(self, model: ir.Model | str, onnx_shape_inference=False, **kwargs):
shubhambhokare1
approved these changes
May 12, 2025
gramalingam
approved these changes
May 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simplify conversion of the onnx textual representation to IR.
#2290